/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.com.domain;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "barrios")
@NamedQueries({@NamedQuery(name = "Barrios.findAll", query = "SELECT b FROM Barrios b"), @NamedQuery(name = "Barrios.findByBaBarrio", query = "SELECT b FROM Barrios b WHERE b.baBarrio = :baBarrio"), @NamedQuery(name = "Barrios.findByBaDescripcion", query = "SELECT b FROM Barrios b WHERE b.baDescripcion = :baDescripcion")})
public class Barrios implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator="barrioGen", strategy=GenerationType.SEQUENCE)
    @SequenceGenerator(sequenceName="barrios_ba_barrio_seq", name="barrioGen")
    @Basic(optional = false)
    @Column(name = "ba_barrio")
    private Integer baBarrio;
    @Column(name = "ba_descripcion")
    private String baDescripcion;
    @OneToMany(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, mappedBy = "baBarrio", fetch = FetchType.LAZY)
    private Set<Denuncias> denunciasSet;
    @JoinColumn(name = "ba_ciudad", referencedColumnName = "ci_ciudad")
    @ManyToOne(fetch = FetchType.LAZY)
    private Ciudades baCiudad;

    public Barrios() {
    }

    public Barrios(Integer baBarrio) {
        this.baBarrio = baBarrio;
    }

    public Integer getBaBarrio() {
        return baBarrio;
    }

    public void setBaBarrio(Integer baBarrio) {
        this.baBarrio = baBarrio;
    }

    public String getBaDescripcion() {
        return baDescripcion;
    }

    public void setBaDescripcion(String baDescripcion) {
        this.baDescripcion = baDescripcion;
    }

    public Set<Denuncias> getDenunciasSet() {
        return denunciasSet;
    }

    public void setDenunciasSet(Set<Denuncias> denunciasSet) {
        this.denunciasSet = denunciasSet;
    }

    public Ciudades getBaCiudad() {
        return baCiudad;
    }

    public void setBaCiudad(Ciudades baCiudad) {
        this.baCiudad = baCiudad;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (baBarrio != null ? baBarrio.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Barrios)) {
            return false;
        }
        Barrios other = (Barrios) object;
        if ((this.baBarrio == null && other.baBarrio != null) || (this.baBarrio != null && !this.baBarrio.equals(other.baBarrio))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.domain.Barrios[baBarrio=" + baBarrio + "]";
    }

}
